
(()=>{
    console.log('启动成功');


    //枚举的使用
    enum Color{
        red,
        blue,
        green
    }

    let color:Color = Color.red;
    console.log(color,Color.red,Color.blue,Color.green);
    

    //any 任意类型
    let andy:any = "你好";
    console.log(andy);
    andy = 23;
    console.log(andy);
    
    let arr:any[] = [234,34,'nihaoa'];
    // arr[0].split('');//报错，因为数字没分割方法
    let t = arr[2].split('');
    console.log(t);
    
    //void .在函数后面写，一般为函数没哟返回值
    function test():void{
        console.log('void的方法被调用！');
    }
    test();

    //联合类型：union type
    function test_union(name:number|string,age:number|string):object{

        return {
            'name':name,
            'age':age
        };
    }
    console.log(test_union('a','b'));
    console.log(test_union(12,23));

    //类型断言  < >  , as 
    function test_asset(name:String):number{
        // return name.toString().length;
        // return (name as String).length;
        return (<string>name).length
    }
    console.log(test_asset("小明"));
    

    //类型推断
    let num= 100
    //num = ''; //推断出是数字不能再赋值为 字符串
    console.log(num);

})()